﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.EventSystems;
using System.Collections.Generic;
using UnityEngine.SceneManagement;

public class EnemyControllScript : MonoBehaviour {

    public string enemyKey;
    public float enemyHealth;
    public float enemyDamage;
    Sprite enemySprite;

	void Update ()
    {
		if(enemyHealth <= 0)
        {
            List<CraftMaterialAmount> loot = SingletonManager.GenerateLootList(2);
            PlayerInventory.Add(loot);
            Destroy(gameObject);
        }
	}

    public void Spawn()
    {
        EnemyClass enemy = SingletonManager.FindEnemy(enemyKey);
        enemyHealth = enemy.enemyHealth;
        enemyDamage = enemy.enemyDamage;
        enemySprite = SingletonManager.GetSprite(enemy);
        gameObject.GetComponent<SpriteRenderer>().sprite = enemySprite;
    }
}
